package com.ruoyi.service.reward.enums;

import com.ruoyi.service.account.enums.IOFlagEnum;
import lombok.Getter;

/**
 * <p>
 * 作用：变动类型
 * </p>
 *
 * @author Zane
 * @since 2025-10-05 21:15
 */
@Getter
public enum RewardTypeEnum {
  JL("JL", "奖励", IOFlagEnum.IN, "平台奖励"),
  CF("CF", "处罚", IOFlagEnum.OUT, "平台处罚");
  /**
   * 编码
   */
  private final String code;

  /**
   * 输入输出标识  锁定 0 ,入账 1, 出账 -1
   */
  private final IOFlagEnum ioFlag;
  /**
   * 名称
   */
  private final String name;
  /**
   * 描述
   */
  private final String desc;

  RewardTypeEnum(String code, String name, IOFlagEnum ioFlag, String desc) {
    this.code = code;
    this.name = name;
    this.ioFlag = ioFlag;
    this.desc = desc;
  }

  public boolean eqCode(String code) {
    return this.code.equals(code);
  }

  public static RewardTypeEnum valueOfCode(String changeType) {
    for (RewardTypeEnum value : RewardTypeEnum.values()) {
      if (value.eqCode(changeType)) {
        return value;
      }
    }
    throw new IllegalArgumentException("奖惩类型不合法");
  }

}
